<!DOCTYPE html>
<html lang="en">
<head>
    <title>账号管理</title>
    {% include 'admin/common/header.html' %}
    <link rel="stylesheet" href="{{ url_for('static', filename='admin/admin/css/other/user.css') }}"/>
</head>
<body class="pear-container">
{# 查询表单 #}
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="" lay-filter="record-query-form">
            <div class="layui-form-item">
                <label class="layui-form-label">批次编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="batch_no" placeholder="" class="layui-input">
                </div>

                <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="record-query">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
                <button type="reset" class="pear-btn pear-btn-md">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>
        </form>
    </div>
</div>
{# 表格 #}
<div class="user-main user-collasped">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="record-table" lay-filter="record-table"></table>
        </div>
    </div>
</div>
</body>

{# 修改操作 #}
<script type="text/html" id="record-bar">
    {% if authorize("walmart:record:main") %}
        <button class="pear-btn pear-btn-primary pear-btn-md" lay-event="detail">
            <i class="pear-icon pear-icon-code">记录详情</i>
        </button>
    {% endif %}
</script>

<script type="text/html" id="user-createTime">
    {{ '  {{layui.util.toDateString(d.create_at,  "yyyy-MM-dd HH:mm:ss")}' |safe }}}
</script>

{% include 'admin/common/footer.html' %}

<script>
    layui.use(['table', 'form', 'jquery', 'popup', 'common'], function () {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let popup = layui.popup;
        let MODULE_PATH = '/walmart/record/'

        // 表格数据
        let cols = [
            [
                {title: '批次编号', field: 'batch_no', align: 'center'},
                {title: '总数', field: 'total', align: 'center'},
                {title: '中签数', field: 'zhong_qian_num', align: 'center'},
                {#{ title: '获取短信返回结果', field: 'msg_result', align: 'center', width:'50%' },#}
                {title: '创建时间', field: 'create_at', templet: '#user-createTime', align: 'center'},
                {title: '操作', toolbar: '#record-bar', align: 'center'}
            ]
        ]

        // 渲染表格数据
        table.render({
            elem: '#record-table',
            url: MODULE_PATH + 'data',
            page: true,
            cols: cols,
            skin: 'line',
            height: 'full-148',
            text: {none: '暂无调用记录'},
            defaultToolbar: [{layEvent: 'refresh', icon: 'layui-icon-refresh'}, 'filter', 'print', 'exports'] /*默认工具栏*/
        })

        table.on('tool(record-table)', function (obj) {
            if (obj.event === 'detail') {
                window.detail(obj)
            }
        })


        form.on('submit(record-query)', function (data) {
            window.refresh(data.field)
            return false
        })


        window.refresh = function (param) {
            table.reload('record-table', {where: param})
        }

        window.detail = function (obj) {
            layer.open({
                type: 2,
                title: '记录详情',
                shade: 0.1,
                area: ['90%', '95%'],
                content: MODULE_PATH + 'detailPage/' + obj.data['batch_no']
              })
        }

    })
</script>
</html>